<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>长沙国王陵遗址信息管理系统登录</title>
<link href="${path}/css/alogin.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="${path}/imgs/favicon.ico.png" type="image/x-icon"/>
<link rel="shortcut icon" href="${path}/imgs/favicon.ico.png" type="image/x-icon"/>
<script type="text/javascript" src="${path}/js/jquery-1.11.2.min.js"></script>
</head>
<body>
	<form id="form1" style="display: block; margin-top: 0em;" method="post">
		<div class="Main">
			<ul>
				<li class="top"></li>
				<li class="top2"></li>
				<li class="topA"></li>
				<li class="topB"><span> <img src="${path}/imgs/logo.png"
						alt="" style="width: 140px;height: 140px;align:center;opacity: 50; margin-left: 80px; " />
				</span></li>
				<li class="topC"></li>
				<li class="topD">
					<ul class="login">
						<li><span class="left">用户名:</span> <span style="">
								<input id="userName" type="text" name="userName" class="txt" placeholder="请输入用户名" />
						</span></li>
						<li><span class="left">密&nbsp;&nbsp;&nbsp;码:</span>
							<span style=""> <input id="password" type="password"
								name="password" class="txt" placeholder="请输入密码"  value=""/>
						</span></li>
						<li><span class="left">验证码:</span> <span style="">
								<input id="code" type="text" class="txtCode" placeholder="请输入验证码" /> <span
								id="hide_span"></span><a style="margin-top: 5px;"> <img
									src="${path}/user/mgr/createCert" id="certcode"
									class="certCode" onclick="showCertCode()" width="53"
									height="25" title="看不清，点击刷新" />看不清 换一张
							</a>
						</span></li>
					</ul>
					<div style="margin-left: 20px;margin-top: 10px;color: red;" id="error_msg"></div>
				</li>
				<li class="topE"></li>
				<li class="middle_A"></li>
				<li class="middle_B"></li>
				<li class="middle_C"><span class="btn"><img alt=""
						src="${path}/imgs/btnlogin.gif" onclick="onLoginClick();" />
				</span><br/>
				<span class="btn"><a href="javascript:void(0)" onclick="quikeLogin();">快速登陆(开发测试)</a>
				</span></li>
				<li class="middle_D"></li>
				<li class="bottom_A"></li>
				<li class="bottom_B">
					<div style="margin-top: 20px">Copyright &copy;
						长沙国王陵遗址公园</div>
				</li>
			</ul>
		</div>
	</form>
	<script type="text/javascript">
		function onLoginClick() {
			var userName = $("#userName").val();
			var password = $("#password").val();
			var code = $("#code").val();
			if(!userName){
				$("#error_msg").html("请输入用户名!");
				return;
			}
			if(!password){
				$("#error_msg").html("请输入密码!");
				return;
			}
			if(!code){
				$("#error_msg").html("请输入图片验证码!");
				return;
			}
			$.ajax({
				type : "post",
				cache : false,
				async : false,
				url : "${path}/user/mgr/dologin",
				data : {
					jobNo : userName,
					pwd : password,
					code : code
				},
				success : function(json) {
					if (json == "true") {
							var url = "${path}/mgr/home";
							if (window.parent) {
								window.parent.location.href = url;
							} else {
								window.location.href = url;
							}
					} else {
						$("#error_msg").html(json);
						return;
					}
				}
			});
		}
		function showCertCode() {
			var url = "${path}/user/mgr/createCert?flag=" + Math.random();
			$("#certcode").attr("src", url);
		};
		//回车事件	
		document.onkeydown = function() {
			var EventUtil = {};
			EventUtil.getEvent = function() {
				if (window.event) {
					return window.event;
				} else {
					return EventUtil.getEvent.caller.arguments[0];
				}
			};
			if (EventUtil.getEvent().keyCode == 13) {
				onLoginClick();
			}
		};
		function quikeLogin() {
	           $.ajax({
	               type : "post",
	               cache : false,
	               async : false,
	               url : "${path}/user/mgr/quikeLogin",
	               success : function(json) {
	                   if(json!="true"){
	                       return;
	                   }
	                   setTimeout(function() {
	                       var url = "${path}/mgr/home";
	                       if (window.parent) {
	                           window.parent.location.href = url;
	                       } else {
	                           window.location.href = url;
	                       }
	                   }, 1500);
	               }
	           });
	       }
	</script>
</body>
</html>